package nc.ui.arap.badacc;

import nc.ui.pub.bill.BillEditEvent;
import nc.ui.pub.bill.BillEditListener;
import nc.vo.arap.badacc.DstlCaseVO;

public class OnBodyRowChangeListener implements BillEditListener {
	
	 private DstlCaseMainPanel mainPanel;
	 
	public OnBodyRowChangeListener(DstlCaseMainPanel mainPanel) {
		this.mainPanel = mainPanel;
	}

	public void afterEdit(BillEditEvent e) {
		
	}

	public void bodyRowChange(BillEditEvent e) {
		if (e == null || e.getRow() < 0) return;
		DstlCaseState state = createDstlCase(mainPanel.getSelectedVO());
		mainPanel.changeDstlSate(state);
	}
	
	private DstlCaseState createDstlCase(DstlCaseVO caseVO) {
		if (caseVO.getStartflag() == null || Integer.valueOf(0).equals(caseVO.getStartflag())) {
			return InitDstlCaseState.getInstance();
		} else if (Integer.valueOf(1).equals(caseVO.getStartflag())) {
			return StartDstlCaseState.getInstance();
		} else if (Integer.valueOf(2).equals(caseVO.getStartflag())) {
			return EndDstlCaseState.getInstance();
		} else {
			return EmptyDstlCaseState.getInstance();
		}
	}

}
